package com.practice.javabase.jdk8.functionalInterface;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.Method;

import java.util.function.Supplier;

/**
 * @功能：
 * @版本： V1
 * @版权： 信息技术有限公司（http://www.mychery.com/）
 * @作者： 磐石战队开发组  00355760
 * @日期： 2024/8/9 14:29
 */
public class SupplierTest {

    public static void main(String[] args) {
        final User user = User.builder().name("hcg").disabled(true).build();
    }

    public static void test1() {
        Supplier<User> supplier = new Supplier<User>() {
            @Override
            public User get() {
                User user = new User();
                user.setName("hcg");
                return user;
            }
        };
        System.out.println(supplier.get());
    }

    public static <T, R> void test2(R r,MethodSupplier<T,R>... methodSuppliers) {
        if (ObjectUtil.isNull(r)) {
            throw new NullPointerException("r is null");
        }
        for (MethodSupplier<T,R> methodSupplier : methodSuppliers) {
            final String name = methodSupplier.getClass().getName();

            methodSupplier.get(r);
        }
        Supplier<User> supplier = () -> {
            User user = new User();
            user.setName("hcg");
            return user;
        };
        System.out.println(supplier.get());
    }

    private static <T> String getMethodName(MethodSupplier methodSupplier){
        try {
            Class methodSupplierClass =  methodSupplier.getClass();
            Method method = methodSupplierClass.getDeclaredMethod("writeReplace");
        };

    };
}
